<template>
  <div>
    <el-dialog
      ref="refDlg"
      title="考核类别"
      :visible.sync="dialogShow"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :before-close="clearForm"
      width="800px"
      @close="closeDialog"
    >
      <!-- <div> -->
      <div>
        <table-box
          ref="scoringCriteria"
          :selected-arry.sync="tableSelected"
          :table-config="tableConfig"
          :other-filters="otherFilters"
          :off-set="-20"
          show-index
          show-selection
          @selection-change="selectionChange"
        />
        <!-- </div> -->
      </div>
      <div slot="footer">
        <el-button size="mini" @click="closeDialog">返回</el-button>
        <el-button size="mini" type="primary" @click="submitType">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'AddScoreType',
  props: {
    visible: {
      type: Boolean,
      default: false,
      required: true
    },
    detailData: {
      type: [String, Object],
      default: ''
    }
  },
  data() {
    return {
      tableSelected: [],
      otherFilters: [{ 'id': 'scoreNature', 'property': 'scoreNature', 'operator': '=', 'value': 'DAILY' }],
      tableConfig: {
        interfacePath: `${process.env.VUE_APP_BASE_API}/api/v1/configScoreCriteria/page`,
        hideFuncBar: true,
        setting: [
          // {
          //   prop: 'scoreNature',
          //   label: '考核性质',
          //   propEnum: {
          //     domainCode: 'marketing',
          //     appCode: 'slm',
          //     dictTypeCode: 'SCORE_NATURE'
          //   }
          // },
          {
            prop: 'scoreType',
            label: '考核类别'
          },
          {
            prop: 'totalScore',
            label: '总分值'
          },
          {
            prop: 'scoreDesc',
            label: '考核说明'
          }
        ]
      }
    }
  },
  computed: {
    dialogShow: {
      get() {
        return this.visible
      },
      set(val) {
        this.$emit('update:visible', val)
      }
    }
  },
  created() {},
  methods: {
    // 选中行
    selectionChange(rows) {
      this.tableSelected = rows
    },
    // 关闭弹窗
    closeDialog() {
      this.dialogShow = false
      this.clearForm()
    },
    // 关闭弹窗前的回调
    clearForm(done) {
      this.queryObj = {
        id: null
      }
      this.tableData = []
      this.$refs.refForm && this.$refs.refForm.clearValidate()
      done && done()
    },
    // 新增考核类型
    submitType() {
      this.closeDialog()
      this.$emit('addType', this.tableSelected)
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
